package com.nancal.activiti.service.impl;

import com.nancal.activiti.dao.ModelImageMapper;
import com.nancal.activiti.service.ModelImageService;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.repository.Model;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ModelImageServiceImpl implements ModelImageService {

    @Autowired
    private ModelImageMapper modelImageMapper;
    @Autowired
    RepositoryService repositoryService;

    @Override
    public String findSvgByModelId(String deploymentId) {
        Model model = repositoryService.createModelQuery().deploymentId(deploymentId).singleResult();
        return modelImageMapper.findSvgByModelId(model.getId());
    }

    @Override
    public void addSvgAndModelId(String modelId, String svg) {
        modelImageMapper.addSvgAndModelId(modelId,svg);
    }

    @Override
    public void addSvgBytesAndModelId(String modelId, byte[] svg_xmls) {
        modelImageMapper.addSvgBytesAndModelId(modelId,svg_xmls);
    }

    /**
     * 根据modelId添加绑定的文件信息
     * @param fileName
     * @param modelId
     */
    @Override
    public void addFileByModelId(String fileName, String modelId) {
        modelImageMapper.addFileByModelId(fileName,modelId);
    }

    @Override
    public String findFileBymodelId(String modelId) {
        return modelImageMapper.findFileBymodelId(modelId);
    }


    /**
     * 保存模板，模板图片，关联表单信息
     * @param modelId
     * @param svg_xmls
     * @param tableForm
     */
//    @Override
//    public void addSvgBytesAndModelId(String modelId, byte[] svg_xmls,String tableForm) {
//        modelImageMapper.addSvgBytesAndModelId(modelId,svg_xmls,tableForm);
//    }
}
